package com.wh.base.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import cn.dev33.satoken.interceptor.SaAnnotationInterceptor;

@Configuration
@EnableWebMvc
public class SaTokenConfigure implements WebMvcConfigurer  {
	
	// 注册Sa-Token的注解拦截器，打开注解式鉴权功能 
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        // 注册注解拦截器，并排除不需要注解鉴权的接口地址 (与登录拦截器无关)
        registry.addInterceptor(new SaAnnotationInterceptor()).addPathPatterns("/**")
        .excludePathPatterns("/api/**")
        .excludePathPatterns("/login")
        .excludePathPatterns("/static/**")
        .excludePathPatterns("/font/**")
        .excludePathPatterns("/doc.html");

    }
    
    /**
     * 静态资源路径
     */
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
    	registry.addResourceHandler("/static/**")
                .addResourceLocations("classpath:/static/")
        ;
    }  

}
